{extend name="common/base" /}
{block name="title"}添加banner{/block}
{block name="main"}
<script src="/ad/js/g_add/g_add.js"></script>
     <!-- Navigation -->
	   <div id="page-wrapper">
        <div class="col-md-12 graphs">
		<div class="xs">
  	    <h3>{$res['article_id']?"编辑banner":"添加banner"}</h3>
        <div class="well1 white">
        <h5 ><a href="{:url('Banner/b_list')}"><span class="label label-success">返回列表</span></a></h5>
        </div>
  	    <div class="well1 white">
        <form class="form-floating" id="g_add" novalidate="novalidate" ng-submit="submit()" action="{:url('Banner/dob_add')}" method ='post' enctype="multipart/form-data">
          <fieldset>
            <div class="form-group">
              <label class="control-label">banner名称</label>
              <input name="b_title" type="text" class="form-control1 article_title" value="{$res['b_title']?$res['b_title']:''}" required="">
              <input type="hidden" name="b_id" value="{$res['b_id']?$res['b_id']:''}">
            </div>
              <div class="form-group">
                  <label class="control-label">链接地址</label>
                  <input name="b_url" type="text" class="form-control1 article_title" value="{$res['b_url']?$res['b_url']:''}" required="">
                  <input type="hidden" name="b_id" value="{$res['b_id']?$res['b_id']:''}">
              </div>
              <div class="form-group">
                  <label class="control-label">banner图片</label>
                  <input  type="file" ng-model="model.file" required="" id="exampleInputFile">
                  <!-- 显示图片的地方 -->
                  <div id="destination" style="margin-top:10px;">
                      <input type="hidden" name="b_img" value="{$res['b_img']?$res['b_img']:''}">
                      <img src="{$res['b_img']?$res['b_img']:''}" style="width:100px;"></div>

              </div>
            <div class="form-group">
              <button type="button" class="btn btn-primary">{$res['article_id']?"提交":"下一步"}</button>
              <button type="reset" class="btn btn-default">重置</button>
            </div>
          </fieldset>
        </form>
      </div>
    </div>
            <script type="text/javascript">
                document.getElementById('exampleInputFile').addEventListener('change', function() {
                    var file;
                    var destination = document.getElementById('destination');
                    destination.innerHTML = '';

                    // 循环用户多选的文件
                    for(var x = 0, xlen = this.files.length; x < xlen; x++) {
                        file = this.files[x];
                        if(file.type.indexOf('image') != -1) { // 非常简单的交验

                            var reader = new FileReader();

                            reader.onload = function(e) {
                                var img = new Image();
                                var input = document.createElement("input");
                                input.type = 'hidden';
                                input.value = e.target.result;
                                input.name = 'b_img';
                                img.src = e.target.result; // 显示图片的地方
                                img.width = 100;
                                destination.appendChild(img);
                                destination.appendChild(input);
                            };

                            reader.readAsDataURL(file);
                        }
                    }
                });
                //隐藏提示消息
                /*window.onload = function(){
                 setInterval(function(){
                 $("#jg").fadeOut(1000);
                 }, 3000);
                 }*/
            </script>
		{/block}



